package com.googlecode.connectlet.crypto.rsa.provider;

import java.security.KeyPair;
import java.security.KeyPairGeneratorSpi;
import java.security.SecureRandom;

public final class RSAKeyPairGenerator extends KeyPairGeneratorSpi {
	private int thisKeySize = 2048;

	@Override
	public KeyPair generateKeyPair() {
		RSAPrivateCrtKeyImpl privateKey = new RSAPrivateCrtKeyImpl(thisKeySize);
		return new KeyPair(new RSAPublicKeyImpl(privateKey.getPrimeP().multiply(privateKey.getPrimeQ())), privateKey);
	}

	@Override
	public void initialize(int keysize, SecureRandom random) {
		thisKeySize = keysize;
	}
}